var jug = new Juggernaut;

var offline = $("<div></div>")
    .html("The connection has been disconnected! <br /> " + 
          "Please go back online to use this service.")
    .dialog({
        autoOpen: false,
        modal:    true,
        width:    330,
        resizable: false,
        closeOnEscape: false,
        title: "Connection"
    });

jug.on("connect", function(){ 
  offline.dialog("close");
});

jug.on("disconnect", function(){ 
  offline.dialog("open");
});

// Once we call subscribe, Juggernaut tries to connnect.
jug.subscribe("channel1", function(data){
  console.log("Got data: " + data);
});